<?php
require '../common.php';


$str = $_SERVER['HTTP_REFERER'];
$arr = explode("/", $str);
$flag = $arr[count($arr) - 1];



if ($flag == "article.php") {
    $id = $_GET["id"];
    $tags = getAll("select * from tag");
    $article = getOne("select article.*,tag.name as tag_name from article left join tag on article.tag_id= tag.id
             where article.id='$id'");

    $smarty->assign("tags", $tags);
    $smarty->assign("article", $article);


    //require 'templates/edit.html';
    $smarty->display("edit.html");
} elseif ($flag == "tag.php") {

    $id = $_GET['id'];
    $tag = getOne("select * from tag where id='$id'");

    $smarty->assign("tag", $tag);
    $smarty->display("edit_tag.html");
    //require 'templates/edit_tag.html';

}

?>